// 数据库操作
const mongoose = require('mongoose');
// 对象规则验证
const Joi = require('joi');
// 模型规则类
const {
    Schema
} = mongoose;

// 订单模型规则
const orderLogSchema = new Schema({
    // 被变更的订单id
    oid: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Order',
        required: true
    },
    // 员工id
    sid: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: true
    },
    // 操作时间
    createTime: {
        type: Date,
        required: true,
        default: Date.now()
    },
    // 此次改变后的内容
    content: {
        type: String,
        required: true,
        default: null
    }
}, {
    versionKey: false
});

const OrderLog = mongoose.model('OrderLog', orderLogSchema);

// 导出模块成员
module.exports = {
    OrderLog
}